package com.share.ai.langchain4j.config;

import dev.langchain4j.data.message.ChatMessage;
import dev.langchain4j.store.memory.chat.ChatMemoryStore;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

//实现存储即可
@Component
public class PersistentChatMemoryStore implements ChatMemoryStore {
    private static Map<Object, List<ChatMessage>> map = new HashMap<>();

    @Override
    public List<ChatMessage> getMessages(Object memoryId) {
        return map.get(memoryId);
    }

    @Override
    public void updateMessages(Object memoryId, List<ChatMessage> list) {
        map.put(memoryId, list);
    }

    @Override
    public void deleteMessages(Object memoryId) {
        map.remove(memoryId);
    }
}
